package com.pinc.poop;


import android.text.format.Time;

public class PincDate extends Time {

	public PincDate() {
		super();
	}

	public PincDate(Time other) {
		super(other);
	}

	public PincDate go2LastDayofMonth()
	{
		this.monthDay = super.getActualMaximum(Time.MONTH_DAY);
		super.normalize(false);
		return this;
	}

	public PincDate go2FirstDayofMonth()
	{
		this.monthDay = 1;
		super.normalize(false);
		return this;
	}

	public PincDate go2FirstDayofWeek()
	{
		this.monthDay -= this.weekDay;
		super.normalize(false);
		return this;
	}

	public PincDate go2LastDayofWeek()
	{
		this.monthDay += getActualMaximum(Time.WEEK_DAY) - weekDay;
		super.normalize(false);
		return this;
	}

	public PincDate setDate(Time t)
	{
		this.year = t.year;
		this.month = t.month;
		this.monthDay = t.monthDay;
		super.normalize(false);
		return this;
	}

	public PincDate nextDay(int n)
	{
		this.monthDay+=n;
		super.normalize(false);
		return this;
	}

	public PincDate nextMonth(int n)
	{
		this.month+=n;
		super.normalize(false);
		return this;
	}

	public String toDateStr(){
		return format("%Y%m%d");
	}

	public String toTimeStr(){
		return format("%H%M");
	}

	public boolean SameDay(PincDate myd)
	{
		return ( this.year == myd.year && this.yearDay == myd.yearDay);
	}

	public long diffInMins(PincDate t1)
	{
		long millis = t1.toMillis(true) - toMillis(true);
		long mins = millis/1000/60;
		return mins;
	}
}
